import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:flutter/material.dart';

class ListHeaderItem extends StatelessWidget {
  final String title;
  final List<InlineSpan> titleSpans;
  final Widget rightIcon;
  final bool hasBackgroundColor;
  final EdgeInsets padding;
  final FontWeight fontWeight;
  const ListHeaderItem(
      {Key key,
      this.title,
      this.hasBackgroundColor = true,
      this.titleSpans,
      this.rightIcon,
      this.padding,
      this.fontWeight = FontWeight.w400})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    Widget textWidget;
    if (title != null) {
      textWidget = Text(
        title,
        style: TextStyle(
          color: aceDarkGrayColor,
          fontSize: getSp(16),
          fontWeight: fontWeight,
          height: 22 / 16,
        ),
      );
    }
    if (titleSpans != null) {
      textWidget = Text.rich(TextSpan(
          children: titleSpans,
          style: TextStyle(
            color: aceDarkGrayColor,
            fontSize: getSp(16),
            fontWeight: FontWeight.w400,
            height: 22 / 16,
          )));
    }
    return Container(
      height: getDp(32),
      color: hasBackgroundColor == true ? aceWhiteColor : null,
      padding: padding ?? EdgeInsets.symmetric(horizontal: getDp(24)),
      alignment: Alignment.centerLeft,
      child: Row(
        children: [
          Expanded(
            child: textWidget,
          ),
          if (rightIcon != null) rightIcon,
        ],
      ),
    );
  }
}
